#include<stdio.h>

int atoi(const char *s)
{
    int result=0;
    int sign=1;
    if(*s=='-')
    sign = -1;
    while(*s!='\0')
    {
        if(*s>='0'&&*s<='9')
        result=result*10+*s-'0';
        s++;
    }
    return result * sign;
}


int main()
{
    const char *str = "-12345";
    int a = atoi(str);
    printf("%d\n",a);
    return 0;
}